/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import java.util.ArrayList;
import models.Student;

/**
 *
 * @author plato
 */
public class SearchUtils {

    public ArrayList<Student> searchInList(String typeSearch,ArrayList<Student> list, String inputSearch) {
        ArrayList<Student> resultToForm = new ArrayList<>();
        if (typeSearch.equals("First Name")) {
            for (Student student : list) {
                if(student.getFirstName().toLowerCase().contains(inputSearch.toLowerCase())) {
                    resultToForm.add(student);
                }
            }
        }
        if (typeSearch.equals("Last Name")) {
            for (Student student : list) {
                if(student.getLastName().toLowerCase().contains(inputSearch.toLowerCase())) {
                    resultToForm.add(student);
                }
            }
        }
        if (typeSearch.equals("Address")) {
            for (Student student : list) {
                if(student.getAddress().toLowerCase().contains(inputSearch.toLowerCase())) {
                    resultToForm.add(student);
                }
            }
        }
        if (typeSearch.equals("Age")) {
            for (Student student : list) {
                if(Integer.toString(student.getAge()).toLowerCase().contains(inputSearch.toLowerCase())) {
                    resultToForm.add(student);
                }
            }
        }
        if (typeSearch.equals("Dob")) {
            for (Student student : list) {
                if(student.getDob().toLowerCase().contains(inputSearch.toLowerCase())) {
                    resultToForm.add(student);
                }
            }
        }
        if (typeSearch.equals("Note")) {
            for (Student student : list) {
                if(student.getNote().toLowerCase().contains(inputSearch.toLowerCase())) {
                    resultToForm.add(student);
                }
            }
        }
        return resultToForm;

    }
}
